<?php
	if(!isset($_REQUEST['ajax'])){ $_REQUEST['ajax'] = "";}
	if($_REQUEST['ajax']!=true) include 'header.tpl.php';
?>
	<div class="row">
		<div class="col-lg-12">
			<ul class="shortcut-buttons-set">
				<li>
					<a class="shortcut-button" href='#finance_list/status=0'><span>
					<i class="aicon-task_list"></i>
					<?php echo $this->language['list'];?></span></a>
				</li>
				<?php if(check_permission('import_receipt')){ ?>
				<li>
					<a class="shortcut-button" href='#import/mod=thuchi'><span>
					<i class="aicon-receipt"></i>
					<?php echo $this->language['import_receipt_payment'];?></span></a>
				</li>
				<?php } ?>
				<?php if(check_permission('import_bank')){ ?>
				<li>
					<a class="shortcut-button" href='#import/mod=nganhang'><span>
					<i class="aicon-salary_kt"></i>
					<?php echo $this->language['import_banks'];?></span></a>
				</li>
				<?php } ?>
			</ul>
		</div>
	</div>
	<div class="row">
		<div class="col-lg-12">
			<div class="panel">
				<div class="panel-heading">
					<div class="panel-title"><i class="icon-cog"></i> <?php echo $this->language['list'];?></div>
				</div>
				<div class="panel-body">
					<form action="javascript:doSearchPay();" class="form-inline">
						<label><?php echo $this->language['search'];?> : </label>
						<input type="text" class="form-control" placeholder="<?php echo $this->language['name'];?> / <?php echo $this->language['reason'];?>" id="search_tieuchi">
						<input type="text" class="form-control" placeholder="<?php echo $this->language['date'];?>" id="search_ngay">
						<input type="submit" value="<?php echo $this->language['search'];?>" class="btn btn-warning" >
					</form>
					<table class="table table-fixed table-hover table-condensed">
						<thead>
							<tr>
								<th width='40px'><?php echo $this->language['type'];?></th>
								<th width='140px'><?php echo $this->language['receip_payment_person'];?></th>
								<th><?php echo $this->language['reason'];?></th>
								<th width="85px"><?php echo $this->language['amount_money'];?></th>
								<th width="85px"><?php echo $this->language['date'];?></th>
								<th width='50px'></th>
							</tr>
						</thead>
						<tbody>
							<?php if(isset($this->payments)){
								foreach($this->payments as $row){ ?>
							<tr>
								<td><?php
									if($row['pay_type']=='1') echo "<font color=green>".$this->language['receip']."</font>";
									elseif($row['pay_type']=='0') echo "<font color=red>".$this->language['payment']."</font>";
									else echo "<font color=purple>".$this->language['unknown']."</font>";
								?></td>
								<td><?php echo $row['pay_name'];?></td>
								<td><a href='#finance_view/id=<?php echo $row['pay_id'];?>'><?php echo $row['pay_description'];?></a></td>
								<td>
								<?php
									if($row['pay_type']=='1') echo "<font color=green>+ ".number_format($row['pay_amount'],0,'',',')."</font>";
									elseif($row['pay_type']=='0') echo "<font color=red>- ".number_format($row['pay_amount'],0,'',',')."</font>";
									else echo "<font color=purple>".number_format($row['pay_amount'],0,'',',')."</font>";
								?>
								</td>
								<td><?php echo date("d/m/Y",$row['pay_date']);?></td>
								<td>
									<a href='#finance_view/id=<?php echo $row['pay_id'];?>'><img src="resources/images/icons/view.png" /></a>
									<?php if(check_permission('bussiness_view')) : ?>
									<a href='javascript:delete_payment(<?php echo $row['pay_id'];?>);'><img src="resources/images/icons/cross.png" /></a>
									<?php endif;?>
								</td>
							</tr>
							<?php }} ?>
						</tbody>
						<?php if(isset($this->tfoot)) echo $this->tfoot;?>
					</table>
				</div>
			</div>
		</div>
	</div>
	<script type="text/javascript" src="resources/scripts/jquery-ui.min.js"></script>
	<script type="text/javascript" src="resources/scripts/jquery.datePicker.js"></script>
	<script>
	$(function() {
		$( "#search_ngay" ).datepicker({dateFormat: 'dd-mm-yy'});
	});
	</script>
<?php if(isset($this->breadcrumb) && isset($this->title_header)):?>
	<script type="text/javascript">
		$(function() {
			$("#title-header").text('<?php echo $this->title_header;?>');
			$("#breadcrumb").html('<?php echo build_breadcrumb($this->breadcrumb);?>');
		});
	</script>
<?php endif;?>
<?php
	if($_REQUEST['ajax']!=true) include 'footer.tpl.php';
?>